var express = require('express')
var compression = require('compression')
var history = require('connect-history-api-fallback')
var serveStatic = require('serve-static')
var port = process.env.PORT || 6777
// Serve up public/ftp folder
var serve = serveStatic('build', {
  maxAge: '1y',
  setHeaders: setCustomCacheControl
})
var app = express()
app
  .use(compression())
  .use(history())
  .use(serve)
  .listen(port)
function setCustomCacheControl(res, path) {
  if (serveStatic.mime.lookup(path) === 'text/html') {
    // Custom Cache-Control for HTML files
    res.setHeader('Cache-Control', 'no-cache, must-revalidate')
  }
}